Skip to content

Split DotnetMuxerLocator into platform-focused modules - #11534

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
copilot/refactor-dotnetmuxerlocator
Sep 27, 2026
Merged

Amaury Levé (Evangelink) merged 4 commits into
mainfrom
copilot/refactor-dotnetmuxerlocator

Conversation

Copilot AI commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

DotnetMuxerLocator.cs had grown to 573 lines, combining discovery orchestration with platform-specific binary parsing.

  • Core locator

    • Retains muxer discovery, architecture validation, and platform detection.
    • Preserves existing nested types and API shape.
  • Windows

    • Moves PE header parsing into DotnetMuxerLocator.Windows.cs.
  • macOS

    • Moves Mach-O constants, parsing helpers, and CPU types into DotnetMuxerLocator.MacOs.cs.

The implementation remains one logical type through partial class declarations:

internal sealed partial class DotnetMuxerLocator

Copilot AI balanced review requested due to automatic review settings September 25, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 25, 2026 19:05
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor DotnetMuxerLocator.cs into focused modules Split DotnetMuxerLocator into platform-focused modules Sep 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new adapted-source files need attribution and vendored-manifest tracking.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Low severity

Open (2)

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Sep 25, 2026
@github-actions github-actions Bot removed the state/needs-review Awaiting review from the team. label Sep 25, 2026
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review September 27, 2026 11:47
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Sep 27, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@github-actions github-actions Bot removed the state/needs-review Awaiting review from the team. label Sep 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review outcome: No actionable findings — this is a clean, behavior-preserving code-movement refactor.

Change classification

  • Code organization only: DotnetMuxerLocator becomes internal sealed partial class, splitting its Windows PE-header parsing and macOS Mach-O parsing logic into two new files (DotnetMuxerLocator.Windows.cs, DotnetMuxerLocator.MacOs.cs) while the base file retains shared state, constructor, and orchestration logic (IsValidArchitectureMuxer).
  • No logic changes: Diffed the moved method bodies (GetMuxerArchitectureByPEHeaderOnWin, GetMuxerArchitectureByMachoOnMac, ReadFourBytes, MacOsCpuType enum, Mach-O magic-number constants) line-by-line against the pre-refactor file — byte-identical apart from relocation. GetMuxerArchitectureByPEHeaderOnWin also picked up a static modifier change only in the sense it was already static before the move (confirmed unchanged).

Confidence at a glance

🟢 Correctness & design — clean, verified equivalent
  • Why it applies: Refactor touches core architecture-detection logic used by IsValidArchitectureMuxer, which gates muxer selection.
  • Evidence: IsValidArchitectureMuxer (unchanged, still in base file) calls GetMuxerArchitectureByPEHeaderOnWin(path, _resolutionLog) on Windows and GetMuxerArchitectureByMachoOnMac(path) on macOS/other — both call sites and signatures are identical to pre-refactor. partial modifier correctly applied to all three files; no using directives are missing (System.Buffers.Binary moved into DotnetMuxerLocator.MacOs.cs where it's now used, dropped from the base file where it's no longer needed — correct). No namespace mismatch; all three files share Microsoft.Testing.Platform.MSBuild.Tasks.
  • Gap or disposition: Two pre-existing, non-blocking observations posted as inline NITs (macOS file casing MacOs vs. conventional MacOS, matches existing MacOsCpuType enum so is only a naming nit; and a pre-existing truncated-file EndOfStreamException risk in the PE header reader, unchanged by this PR).
  • Action: None required for merge.
🟢 API & compatibility — clean
  • Why it applies: Class changed from sealed class to sealed partial class; need to confirm no accessibility change and no public API impact.
  • Evidence: All moved/retained members remain internal/private/private static exactly as before — no accessibility widened or narrowed. No project in this repo has a PublicAPI.Unshipped.txt for Microsoft.Testing.Platform.MSBuild (confirmed via search), and none is needed since nothing here is public. partial on an otherwise single-assembly internal sealed class has no ABI/multi-targeting implications; no #if conditional compilation is needed since OS branching is done via RuntimeInformation.IsOSPlatform at runtime, not compile-time — correctly, files are compiled for all TFMs regardless of OS.
  • Gap or disposition: None.
  • Action: None required for merge.
🟢 Tests — clean, coverage preserved
  • Why it applies: Behavior-only-moved code needs confirmation that existing tests still exercise it correctly post-split.
  • Evidence: test/UnitTests/Microsoft.Testing.Platform.MSBuild.UnitTests/DotnetMuxerLocatorTests.cs invokes the private static/instance methods via typeof(DotnetMuxerLocator).GetMethod(methodName, BindingFlags.NonPublic | ...) reflection — this resolves correctly across partial-class file boundaries since reflection operates on the merged type, not the source file. No test changes were needed or made, consistent with a pure refactor.
  • Gap or disposition: None.
  • Action: None required for merge.

⚪ Not applicable: Concurrency & lifecycle, Security & protocol, Performance, Localization, Analyzers, Build/dependencies & scripts (no .props/.targets/dependency changes).

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Sep 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The extraction preserves behavior and API shape, and the vendored-file manifest validates successfully.

Review effort: Balanced
Findings: 2 Low severity

Open (2)

@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/approved Proposal approved; ready for implementation. labels Sep 27, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit c670f66 into main Sep 27, 2026
35 of 37 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/refactor-dotnetmuxerlocator branch September 27, 2026 13:30
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file-diet] Refactor DotnetMuxerLocator.cs (573 lines) into focused modules

4 participants